﻿'This file is part of Alpha.
'
'   Alpha is free software: you can redistribute it and/or modify
'   it under the terms of the GNU Lesser General Public License as published by
'   the Free Software Foundation, either version 3 of the License, or
'   (at your option) any later version.
'
'   Alpha is distributed in the hope that it will be useful,
'   but WITHOUT ANY WARRANTY; without even the implied warranty of
'   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'   GNU Lesser General Public License for more details.
'
'   You should have received a copy of the GNU Lesser General Public License
'   along with Alpha.  If not, see <http://www.gnu.org/licenses/>.

Public Structure Track
    Implements IEquatable(Of Track)

    Private varTitle As String
    Private varArtist As String
    Private varAlbum As String
    Private varLength As Integer
    Private varYear As Integer
    Private varAlbumTrackNo As Integer
    Private varAlbumTotalTracks As Integer
    Private varAlbumDiskNo As Integer
    Private varAlbumTotalDisks As Integer

    Public Property Title() As String
        Get
            Return varTitle
        End Get
        Set(ByVal value As String)
            varTitle = value
        End Set
    End Property
    Public Property Artist() As String
        Get
            Return varArtist
        End Get
        Set(ByVal value As String)
            varArtist = value
        End Set
    End Property
    Public Property Album() As String
        Get
            Return varAlbum
        End Get
        Set(ByVal value As String)
            varAlbum = value
        End Set
    End Property
    Public Property Length() As Integer
        Get
            Return varLength
        End Get
        Set(ByVal value As Integer)
            varLength = value
        End Set
    End Property
    Public Property Year() As Integer
        Get
            Return varYear
        End Get
        Set(ByVal value As Integer)
            varYear = value
        End Set
    End Property
    Public Property AlbumTrackNo() As Integer
        Get
            Return varAlbumTrackNo
        End Get
        Set(ByVal value As Integer)
            varAlbumTrackNo = value
        End Set
    End Property
    Public Property AlbumTotalTracks() As Integer
        Get
            Return varAlbumTotalTracks
        End Get
        Set(ByVal value As Integer)
            varAlbumTotalTracks = value
        End Set
    End Property
    Public Property AlbumDiskNo() As Integer
        Get
            Return varAlbumDiskNo
        End Get
        Set(ByVal value As Integer)
            varAlbumDiskNo = value
        End Set
    End Property
    Public Property AlbumTotalDisks() As Integer
        Get
            Return varAlbumTotalDisks
        End Get
        Set(ByVal value As Integer)
            varAlbumTotalDisks = value
        End Set
    End Property

    Public Shared Operator =(ByVal track1 As Track, ByVal track2 As Track) As Boolean
        Return track1.Equals(track2)
    End Operator

    Public Shared Operator <>(ByVal track1 As Track, ByVal track2 As Track) As Boolean
        If track1.Equals(track2) Then
            Return False
        Else
            Return True
        End If
    End Operator

    Public Overloads Function Equals(ByVal other As Track) As Boolean Implements System.IEquatable(Of Track).Equals
        If varTitle = other.Title _
        And varArtist = other.Artist _
        And varAlbum = other.Album _
        And varLength = other.Length _
        And varYear = other.Year _
        And varAlbumTrackNo = other.AlbumTrackNo _
        And varAlbumTotalTracks = other.AlbumTotalTracks _
        And varAlbumDiskNo = other.AlbumDiskNo _
        And varAlbumTotalDisks = other.AlbumTotalDisks Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
        If TypeOf obj Is Track Then
            Return Equals(CType(obj, Track))
        Else
            Return False
        End If
    End Function

    Public Overrides Function GetHashCode() As Integer
        Dim str As String = varTitle + varArtist + varAlbum + varLength.ToString(Globalization.CultureInfo.InvariantCulture) + varYear.ToString(Globalization.CultureInfo.InvariantCulture) + varAlbumTrackNo.ToString(Globalization.CultureInfo.InvariantCulture) + varAlbumTrackNo.ToString(Globalization.CultureInfo.InvariantCulture) + varAlbumTotalTracks.ToString(Globalization.CultureInfo.InvariantCulture) + varAlbumDiskNo.ToString(Globalization.CultureInfo.InvariantCulture) + varAlbumTotalDisks.ToString(Globalization.CultureInfo.InvariantCulture)
        Return str.GetHashCode()
    End Function

End Structure

Public Enum Action

    Play
    Pause
    PlayPause
    StopPlayback
    NextTrack
    PreviousTrack
    BackTrack
    VolumeUp
    VolumeDown
    GetMute
    SetMute
    ToggleMute
    SetVolume
    GetVolume
    TrackTitle
    TrackArtist
    TrackAlbum
    TrackLength
    TrackGenre
    TrackYear
    AlbumTrackNo
    AlbumTotalTracks
    AlbumDiskNo
    AlbumTotalDisks
    TrackTimeElapsed
    Seek
    FastForward
    GetRepeat
    GetShuffle
    GetRandom
    SetRepeat
    SetShuffle
    SetRandom
    ToggleRepeat
    ToggleShuffle
    ToggleRandom
    EventTrackChanged

End Enum